# 集合的创建
s = set()
print(s, type(s))
s = {1, 2, 3, 4, 1, 2}
print("重复的处理掉：", s, type(s))
s = set([1, 2, 3])  # list  --> set
print("list-->set: ", s)
s = set('123')  # string  --> set
print("string-->set: ", s)
s = set({1: 'a', 'a': 2})  # dict  --> set
print("dict-->set: ", s)  # 获取到 key

print("*" * 20)

# 内置方法
print(s, 1 in s)
print(s, len(s))
print(min({1, 2, 3, 4, 5, 7, 8}))

print("*" * 20)

# 遍历
for i in s:
    print(i)

print("*" * 20)

# 常用方法
s.remove(('a'))
print(s)
s.update({2, 3, 4, 5, 6, 7, 5})
print(s)
s.add(9)
print(s)
s.add(1)
print("s =", s)

# 交集和并集
s1 = {5, 6, 7, 8, 9}
print("s1=", s1)
print("交集", s & s1)
print("并集", s | s1)

# 数组去重
score = [80, 90, 92, 80, 60]
s = set(score)
print(s)

d = {}
# 统计哥哥分数都有几个学生
for i in s:
    t = score.count(i)
    d[i] = t
    # print("得分为%d的学生又%d人"%(i,t))
for k,v in d.items():
    print("得分为%d的学生又%d人" % (k, v))